﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            #region s1

            //ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();
            //// 记得在客户端也要插入IEndPointBehavior   
            //client.Endpoint.Behaviors.Add(new Inspector.MyEndPointBehavior());
            //try
            //{
            //    client.Add(1.1, 2.2);

            //    // 1、调用带元数据参数和返回值的操作   
            //    Console.WriteLine("\n20和35相加的结果是：{0}", client.AddInt(20, 35));
            //    // 2、调用带有数据协定的操作   
            //    ServiceReference1.Student student = client.GetStudent();
            //    Console.WriteLine("\n学生信息---------------------------");
            //    Console.WriteLine("姓名：{0}\n年龄：{1}", student.StudentName, student.StudentAge);
            //    // 3、调用带消息协定的操作   
            //    Console.WriteLine("\n15乘以70的结果是：{0}", client.ComputingNumbers("乘", 15, 70));
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("异常：{0}", ex.Message);
            //}

            //client.Close();
            //Console.ReadKey();

            #endregion

            #region s2

            //ServiceReference2.MyServiceClient client = new ServiceReference2.MyServiceClient();
            //// 记得在客户端也要插入IEndPointBehavior   
            //client.Endpoint.Behaviors.Add(new Inspector.MyEndPointBehavior());
            //try
            //{
            //    client.Add(1.1, 2.2);

            //    // 1、调用带元数据参数和返回值的操作   
            //    Console.WriteLine("\n20和35相加的结果是：{0}", client.AddInt(20, 35));
            //    // 2、调用带有数据协定的操作   
            //    ServiceReference2.Student student = client.GetStudent();
            //    Console.WriteLine("\n学生信息---------------------------");
            //    Console.WriteLine("姓名：{0}\n年龄：{1}", student.StudentName, student.StudentAge);
            //    // 3、调用带消息协定的操作   
            //    Console.WriteLine("\n15乘以70的结果是：{0}", client.ComputingNumbers("乘", 15, 70));
            //}
            //catch (FaultException ex)
            //{
            //    Console.WriteLine("异常：{0}", ex.Message);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("异常：{0}", ex.Message);
            //}

            //client.Close();
            //Console.ReadKey();

            #endregion


            #region s3

            //ServiceReference3.MyServiceClient client = new ServiceReference3.MyServiceClient();
            //// 记得在客户端也要插入IEndPointBehavior   
            //client.Endpoint.Behaviors.Add(new Inspector.MyEndPointBehavior());
            //try
            //{
            //    //client.Add(1.1, 2.2);

            //    // 1、调用带元数据参数和返回值的操作   
            //    Console.WriteLine("\n20和35相加的结果是：{0}", client.AddInt(20, 35));
            //    // 2、调用带有数据协定的操作   
            //    ServiceReference3.Student student = client.GetStudent();
            //    Console.WriteLine("\n学生信息---------------------------");
            //    Console.WriteLine("姓名：{0}\n年龄：{1}", student.StudentName, student.StudentAge);
            //    // 3、调用带消息协定的操作   
            //    Console.WriteLine("\n15乘以70的结果是：{0}", client.ComputingNumbers("乘", 15, 70));
            //}
            //catch (FaultException ex)
            //{
            //    Console.WriteLine("异常：{0}", ex.Message);
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("异常：{0}", ex.Message);
            //}

            //client.Close();
            //Console.ReadKey();

            #endregion

            #region s4

            ServiceReference4.Service4Client client = new ServiceReference4.Service4Client();
            client.Endpoint.Behaviors.Add(new Common.AuthorizationInspector.AuthorizationBehavior());
            client.DoWork();

            Console.WriteLine("ok");
            Console.ReadLine();

            #endregion
        }
    }
}
